package com.bw.order_module.confirm;

import com.blankj.utilcode.util.ApiUtils;
import com.bw.common.mvvm.model.BaseRespository;
import com.bw.network_sdk.BaseEntity;
import com.bw.network_sdk.HttpType;
import com.bw.network_sdk.NetWorkFactory;
import com.bw.order_module.entity.Order;
import com.bw.order_module.entity.OrderEntity;
import com.bw.order_module.entity.PayEntity;
import com.bw.order_module.entity.PayOrderEntity;
import com.bw.order_module.entity.SubOrderEntity;

import java.util.Map;

import io.reactivex.Observable;

public class ConfirmRespository extends BaseRespository {

    //获取订单详情
    public Observable<BaseEntity>requestDetailOrder(Map<String,Object>map){
        Observable<OrderEntity>orderObservable = NetWorkFactory.factory(HttpType.TOKENSIGN)
                .create(ApiService.class)
                .requestOrderDetail(createBody(map));
        return checkNetWork(orderObservable);
    }

    //确认订单
    public Observable<BaseEntity>requestSubOrder(Map<String,Object>map){
        Observable<SubOrderEntity>subOrderEntityObservable =
                NetWorkFactory.factory(HttpType.TOKEN)
                        .create(ApiService.class)
                        .requestSubOrder(createBody(map));
        return checkNetWork(subOrderEntityObservable);
    }
    //获取支付宝支付签名信息接口
    public Observable<BaseEntity>requestPay(Map<String,Object>map){
        Observable<PayEntity>payEntityObservable =
                NetWorkFactory.factory(HttpType.TOKENSIGN)
                        .create(ApiService.class)
                        .requestPaySign(createBody(map));
        return checkNetWork(payEntityObservable);
    }

    //确认当前订单请求结果
    public Observable<BaseEntity>requestPayOrder(Map<String,Object>map){
        Observable<PayOrderEntity>payOrderEntityObservable =
                NetWorkFactory.factory(HttpType.TOKENSIGN)
                        .create(ApiService.class)
                        .requestPayOrder(createBody(map));
        return checkNetWork(payOrderEntityObservable);
    }
}
